<template>
  <div id="modules-blog">
    <div class="search-box" v-if="$route.meta.noSearch">
      <div class="search-box-wrapper">
        <div class="search-input">
          <el-input @keydown.native.enter="clickSearch" placeholder="请输入内容" v-model="value"> </el-input>
          <el-button @click="clickSearch" icon="el-icon-search" type="primary" plain></el-button>
        </div>
        <div class="template"></div>
      </div>
    </div>
    <div :class="[$route.meta.noSearch ? 'search-header' : '', 'blog-wrapper']">
      <div class="blog-main-item">
        <router-view></router-view>
      </div>
      <div class="blog-aside-item">
        <blog-aside />
      </div>
    </div>
  </div>
</template>

<script>
import blogAside from './blog-aside-item.vue'
export default {
  created() {
    this.value = this.$route.query.value
  },
  beforeRouteUpdate(to, from, next) {
    this.value = to.query.value
    next()
  },
  components: {
    blogAside
  },
  data() {
    return {
      value: ''
    }
  },
  methods: {
    clickSearch() {
      this.$router.replace({
        name: 'refresh',
        query: {
          value: this.value
        }
      })
    }
  }
}
</script>

<style lang="scss">
#modules-blog {
  // position: relative;
  .blog-wrapper {
    display: flex;
    max-width: 1190px;
    min-width: 1190px;
    margin: 0 auto;

    .blog-main-item {
      width: 75%;
    }

    .blog-aside-item {
      width: 25%;
    }
  }
  .search-header {
    margin: 10px auto 0;
  }

  .search-box {
    margin: -29px auto 0;
    box-shadow: 0 0 5px 4px rgba(185, 185, 185, 0.2);
    height: 60px;
    line-height: 60px;
    background: #fff;
    .search-box-wrapper {
      max-width: 1190px;
      min-width: 1190px;
      margin: 0 auto;
      .search-input {
        display: flex;
        width: 75%;
        align-items: center;
        .el-input__inner {
          border-top-right-radius: 0;
          border-bottom-right-radius: 0;
        }
        .el-button {
          width: 100px;
          height: 40px;
          border-top-left-radius: 0;
          border-bottom-left-radius: 0;
        }
      }
      .template {
        width: 25%;
      }
    }
  }
}
</style>
